import './assets/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import router from './router'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import App from './App.vue'

import { createPersistedState } from 'pinia-persistedstate-plugin'

// 添加全局事件监听器配置，使默认支持passive
const originalAddEventListener = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function (type, listener, options) {
    // 对于滚动相关事件，默认添加passive: true
    const modifiedOptions = (options === undefined || options === false || options === true) ?
        { passive: ['scroll', 'wheel', 'touchstart', 'touchmove', 'mousewheel'].includes(type), capture: options === true } :
        { ...options, passive: options.passive !== undefined ? options.passive : ['scroll', 'wheel', 'touchstart', 'touchmove', 'mousewheel'].includes(type) };

    return originalAddEventListener.call(this, type, listener, modifiedOptions);
};

const app = createApp(App)
const pinia = createPinia()
pinia.use(createPersistedState())
app.use(router)
app.use(pinia)
app.use(ElementPlus, {
    locale: zhCn,
    // 设置Element Plus的一些全局选项
    config: {
        scrollbar: {
            always: true
        }
    }
})

app.mount('#app')
